﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PsychveyApp1.classes;

namespace PsychveyApp1
{
    public partial class Signup1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnUserSignup_Click(object sender, EventArgs e)
        {

            UserAccount user = new UserAccount();
            user.userFullName = tbxUserFullName.Text;
            user.nric = tbxUserNRIC.Text;
            user.username = tbxUsername.Text;
            user.password = tbxUserPassword.Text;
            user.retypePassword = RetypeUserPassword.Text;
            user.email = tbxUserEmail.Text;

            user.userID = "PSUser_" + user.username;
            user.expirationDateForPremium = "None";
            user.accountTypeSelected = "Basic";
            user.paymentStatus = "Free User";
            user.listOfSurveys = "";
            user.checkAdministratorStatus = "false";
            user.paymentID = "PaymentOf_" + user.username;
            user.receiptID = "Receipt_" + user.username;
            user.planID = "01";
            DBManager.InsertUser(user);

            string username = tbxUsername.Text;
            string password = tbxUserPassword.Text;
            string accountTypeSelected = user.accountTypeSelected;
            string expirationDateForPremium = user.expirationDateForPremium;

            string querystring = "username=" + username;
            querystring += "&" + "password=" + password;
            querystring += "&" + "accounttypeselected=" + accountTypeSelected;
            querystring += "&" + "expirationdateforpremium=" + expirationDateForPremium;

            Server.Transfer("SignupSuccessful.aspx?" + querystring); 
        }
    }
}